package cn.shentianlan.controller;

import cn.shentianlan.criteria.TeacherCriteria;
import cn.shentianlan.domain.dto.TeacherDTO;
import cn.shentianlan.service.TeacherService;
import cn.shentianlan.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 陈俊源
 * @Description 教师Controller
 * @Date 2021/3/27
 * @Version 1.0
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @PostMapping("/list")
    public Result list(TeacherCriteria criteria){
        Result result = teacherService.findTeacherByCriteria(criteria);
        return result;
    }

    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(TeacherDTO teacherDTO){
        Result result = teacherService.saveOrUpdate(teacherDTO);
        return result;
    }

    @RequestMapping("/getTeacherById")
    public Result getTeacherById(Long id){
        Result result = teacherService.getTeacherById(id);
        return result;
    }

    @RequestMapping("/deleteTeacherById")
    public Result deleteTeacherById(Long id){
        Result result = teacherService.deleteTeacherById(id);
        return result;
    }

}
